home *** CD-ROM | disk | FTP | other *** search
- /*
- File: TSMTextension.h
-
- Contains: xxx put contents here xxx
-
- Written by: Essam Zaky
-
- Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <2> 1/4/94 EZ clean up
- <1> 1/4/94 EZ first checked in
-
- */
-
- #ifndef _TSMTextension_
- #define _TSMTextension_
-
- #ifndef _ToolBoxDump_
- #include "ToolBoxDump.h"
- #endif
-
- #ifndef _Textension_
- #include "Textension.h"
- #endif
-
-
- #ifndef __TEXTSERVICES__
- #include <TextServices.h>
- #endif
-
- #ifndef _TSMRun_
- #include "TSMRun.h"
- #endif
- //***************************************************************************************************
-
- /*
- -Segments:
- -InOut
- -TSMTextension (resident)
- */
- //***************************************************************************************************
-
- //cosnt and types for "fHiliteObjectsData"
-
- struct THiliteObjectData {
- CRunObject* hiliteObj;
- long hiliteFace;
- };
- //***************************************************************************************************
-
- //TKeyDownParams.flags constants (returned from CalcKeyDownParams)
- const TKeyDownFlags kTSMKeyDown = 1 << 11; //••other TKeyDownParams fields are undefined
- //***************************************************************************************************
-
- class CTSMTextension : public CTextension {
-
- public:
- //-------
- static OSErr TSMTextensionStart(CTextensionScrap* localScrap = nil);
- static void TSMTextensionTerminate();
-
- static char CanUseTSM() {return fCanUseTSM;}
- //if false a "CTextension" can be created instead of "CTSMTextension"
-
- static Boolean IsTSMEvent(EventRecord* event);
- //should be called in place of "TSMEvent"
-
- CTSMTextension();
-
- OSErr ITSMTextension(GrafPtr textPort, TTextensionHandlers* handlers, TSize sizeInfo = kLargeSize);
-
- //•override
- virtual void Free();
-
- #ifdef txtnNever
- virtual void ChangeContext(long contextId, Boolean turnSelOn =true);
- #endif
-
- virtual void Activate(Boolean activ, Boolean turnSelOn =true);
-
- virtual void SetSelectionRange(const TOffsetRange& selRange
- , Boolean forceOn = true, Boolean updateKeyScript=true);
-
- virtual Boolean Click(const EventRecord* event, TClickCommandInfo* clickCommandInfo
- , ClickLoopProcPtr clickProc = nil, void* clickProcData = nil);
-
- virtual void CalcKeyDownParams(const EventRecord* event, Boolean bufferKeys, TKeyDownParams* params);
-
- virtual OSErr ReplaceRange(long rangeStart, long rangeEnd, TReplaceParams* replaceParams, Boolean invisible = true);
-
- virtual OSErr UpdateRangeRuns(const TOffsetRange* theRange, const TAttrObjModifier* modifier
- , Boolean invisible=false);
- //overriden sine our inline hole can have only 1 qd face, size, ..
-
- //•own
- Boolean HasActiveInputArea(long* inlineAreaStart, long* inlineAreaEnd);
-
- void FixActiveInputArea();
-
- OSErr UpdateActiveInputEvent(uPtr activText, long activSize, long fixLen,
- TextRangeArrayPtr updateRng,
- TextRangeArrayPtr hiliteRng);
-
- void Pos2OffsetEvent(Point thePt, Boolean dragging
- , short* where, TOffset* charOffset);
- /*
- -thePt is in local coord
- -*where is set to "kTSMOutsideOfBody", "kTSMInsideOfBody" or "kTSMInsideOfActiveInputArea"
- -charOffset->offset is < 0 if *where is "kTSMOutsideOfBody"
- */
-
- OSErr Offset2PosEvent(long offset, Point* thePt
- , short* lineHite, short* lineAscent
- , CRunObject** inlineRun);
- /*
- -returned err is "noErr", "errOffsetInvalid" or "errOffsetIsOutsideView"
- */
-
- #ifdef txtnDebug
- void ShowDebugInfo();
- #endif
-
- protected:
- //----------
- //•override
- virtual CRunObject* UpdatePendingRun();
-
- private:
- //--------
- static char fCanUseTSM;
- static char fTSMInitialized;
- static CObjectsRanges* fHiliteRanges;
-
- TSMDocumentID fTSMDocId;
- long fActivStart; //if < 0 ==> no activ inline area
- long fActivEnd;
-
- CRunObject* fInlineRun;
-
- THiliteObjectData fHiliteObjectsData[kCountTSMFaces];
- char fHiliteObjectsReady;
-
- CRunObject* HiliteStyle2RunObj(short hiliteStyle);
-
- OSErr CalcInlineRunObjects(TextRangeArrayPtr hiliteRng, CObjectsRanges* hiliteObjects, long* caretPos);
-
- void HiliteEvent(CObjectsRanges* newHilites);
-
- OSErr FixActiveInputAreaEvent(uPtr fixText, long fixSize);
-
- void InlineAreaFixed_AdjustRange(long* rangeStart, long* rangeEnd);
-
- #ifdef txtnDebug
- void DumpUpdateData(long activSize, long fixLen
- , TextRangeArrayPtr updateRng
- , TextRangeArrayPtr hiliteRng);
- #endif
- };
- //***************************************************************************************************
-
- #endif
-